package com.marvels.dubbo.externalservice.controller;

import com.marvels.dubbo.externalservice.service.ShortLinkInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("dubbo/user/shortLink/api")
public class ShortLinkServiceController {
	@Autowired
	private ShortLinkInfoService shortLinkService;

	@RequestMapping("insert")
	@ResponseBody
	public String insert(@RequestParam("longUrl") String longUrl, @RequestParam("loanId") String loanId) {
		return shortLinkService.insert(longUrl, loanId);
	}

	@RequestMapping("selectLongUrlByShortUrl")
	@ResponseBody
	public String selectLongUrlByShortUrl(@RequestParam("shortUrl") String shortUrl) {
		return shortLinkService.selectLongUrlByShortUrl(shortUrl);
	}

	@RequestMapping("deleteByloanId")
	@ResponseBody
	public void deleteByloanId(@RequestParam("loanId") String loanId) {
		shortLinkService.deleteByloanId(loanId);
	}

	@RequestMapping("queryLongUrl")
	@ResponseBody
	public String queryLongUrl(@RequestParam("loanId") String loanId) {
		return shortLinkService.queryLongUrl(loanId);
	}

}
